﻿#include <stdio.h>
#include <string.h>

void test(int x[5])
{
    char a[5][6];

    printf("1.%d\n", sizeof(x));
    printf("2.%d\n", sizeof(x[0]));
    printf("3.%d\n", sizeof(a));
    printf("4.%d\n", sizeof(a+0));
    printf("5.%d\n", sizeof(&a));

}

int main(int argc, char *argv[])
{
    float a;
    int zhengshu;
    int xiaoshu1;
    int xiaoshu2;
    float jieguo;

    //printf("plsease input a float: \n");
    //scanf("%f",&a);
    int p[5] = {1,2,3,4,5};
    test(p);
    // (char(*)[9]) 相当于9个字节的 一个结构体
    int x = (char(*)[9])1107 - (char(*)[9])0;
    printf("x =%d \n", x);

    // (int(*)[9]) 相当于9 * 4 个字节的 一个结构体
    int y = (int(*)[9])1107 - (int(*)[9])0;
    printf("y =%d \n", y);

    //printf("zhengshubufenshi: \n");
    /*if(a > 0.0)
    {
        zhengshu = (int)(a+0.5);
        jieguo = (float)((int)(a*100 + 0.5)/100.0);
        printf("jieguo = %0.2f", jieguo);
    }
    else
    {
        zhengshu = (int)(a-0.5);
        jieguo = (float)((int)(a*100 - 0.5)/100.0);
        printf("jieguo = %0.2f", jieguo);
    }*/

    //单井号(#)在宏定义中的作用就是  把传递过来的参数当成字符串进行替换 对应变量字符串化
    #define trace(x, format) printf(#x " = %" #format "\n", x)
    trace(i, d);                // 相当于 printf("x = %d\n", x)
    trace(x, f);                // 相当于 printf("x = %f\n", x)
    trace(s, s);                // 相当于 printf("x = %s\n", x)
    //双井号(##)又称连接符，它的作用就是 将参数和前面或后面的子串连接起来，成为一个新的子串
    #define trace2(i) trace(x##i, d)
    trace2(1);                  // 相当于 trace(x1, d)
    trace2(2);                  // 相当于 trace(x2, d)
    trace2(3);                  // 相当于 trace(x3, d)

#if 0
    /*最近在看经典书籍你必须知道的495个C语言问题时，在复杂申明章节的char * (*(*a[N])())();申明，看书上的解释总是感觉很费解。使用cdecl程序将该源码翻译成英文描述为：declare a as array of pointer to function returning pointer to function returning pointer to char。为了方便理解，可将之进行如下逐级的拆分（使用x代替其余部分）：

    char * x(); declare x as function retruning pointer to char;

    char * (*x)(); declare x as a pointer to function returning pointer to char;

    char * (*x())(); declare x as a function returning pointer to function returning pointer to char;

    char * (*(*x)())(); declare x as a pointer to function returning pointer to function returning pointer to char;

    char * (*(*x[N])())(); declare x as array of pointer to function returning pointer to function returning pointer to char;*/
#endif
    return 0;
}
